package com.jhh.pay.center.search.impl;

import com.alibaba.fastjson.JSON;
import com.jhh.pay.center.search.*;

import java.lang.reflect.ParameterizedType;

/**
 * @author tangxd
 * @Description: TODO
 * @date 2017/11/23
 */
public abstract class AbstractOrderElasticSearcher<T extends AbstractMapping> extends AbstractElasticSearcher {

    @Override
    protected String getIdxName() {
        return "jhh-pay-orders";
    }

    @Override
    protected String getIdxAlias() {
        return "jhh-pay-orders-v1";
    }

    @Override
    public void putMapping() {

    }

    @Override
    protected DocTransformer<T, String> mappingTransformer() {
        return JSON::toJSONString;
    }

    @Override
    protected DocTransformer<String, T> sourceTransformer() {
        return data -> JSON.parseObject(data, (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]);
    }



}
